import java.util.HashMap;
import java.util.Objects;

class Person{
    String name;
    public Person(String name){
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person preson = (Person) o;
        return Objects.equals(name, preson.name);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(name);
    }
}
public class RTHashbucket<K,V> {
    static class Node<K,V>{
        K key;
        V value;
        Node<K,V> next;

        public Node(K key, V value){
            this.key = key;
            this.value = value;
        }
    }
    public Node<K,V>[] array=(Node<K, V>[])new Node[10];
    public int useSized;
    private static final double LOAD_FACTOR=0.75;

    public void put(K key, V value){
        int hash = key.hashCode();
        int index = hash % array.length;
        Node<K,V> cur=array[index];
        while(cur!=null){
            if(cur.key.equals(key)){
                cur.value=value;
            }
            cur=cur.next;
        }
        Node<K,V> newNode=new Node<>(key, value);
        newNode.next=array[index];
        array[index]=newNode;
        useSized++;
        if(Do_LOAD_FACTOR()>=LOAD_FACTOR){
            resize();
        }
    }

    private void resize() {
        Node<K,V>[] newArray=(Node<K, V>[]) new Node[2* array.length];
        for(int i=0;i<array.length;i++){
            Node<K,V> cur=array[i];
            while(cur!=null){
                Node<K,V> curN=cur.next;
                int hash = cur.key.hashCode();
                int index = hash % newArray.length;
                cur.next=newArray[index];
                newArray[index]=cur;
                cur=curN;
            }
        }
        array=newArray;
    }

    private double Do_LOAD_FACTOR() {
        return useSized*1.0/array.length;
    }
    public V getValue(K key){
        int hash = key.hashCode();
        int index = hash % array.length;
        Node<K,V> cur=array[index];
        while(cur!=null){
            if(cur.key==key){
                return cur.value;
            }
            cur=cur.next;
        }
        return null;
    }
}
